package service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.github.miemiedev.mybatis.paginator.domain.Paginator;

import appmodel.AppUserLabel;
import dao.UserNewMapper;
import model.User;
import service.UserService;

@Service
@SuppressWarnings({ "unchecked", "rawtypes" })
public class UserServiceImpl implements UserService {

	@Autowired
	private UserNewMapper userNewMapper;

	// app的login
	@Override
	public User applogin(User paramUser) {
		return this.userNewMapper.appLogin(paramUser);
	}

	@Override
	public User findUser(User paramUser) {
		return this.userNewMapper.findUser(paramUser);
	}

	@Override
	public User getUserInfo(long userId) {
		return this.userNewMapper.getUserInfo(userId);
	}

	public User fingUserByUserId(User user) {
		return this.userNewMapper.fingUserByUserId(user);
	}

	public Map<String, Object> selectAll(PageBounds pageBounds, Map mapValue) {
		List userList = this.userNewMapper.selectAll(pageBounds, mapValue);
		Map map = new HashMap();
		if (userList.size() > 0) {
			PageList pageOrders = (PageList) userList;

			Paginator paginator = pageOrders.getPaginator();
			map.put("list", pageOrders);
			map.put("paginator", paginator);
		}
		return map;
	}

	@Override
	public void insert(User user) {	
		userNewMapper.insert(user);
	}

	@Override
	public void updateByPrimaryKey(User user) {
		userNewMapper.updateByPrimaryKey(user);
	}

	@Override
	public void updateStatus(Map map) {
		userNewMapper.updateStatus(map);
	}

	@Override
	public void modifyAddrInfo(User user) {
		userNewMapper.modifyAddrInfo(user);
	}

	@Override
	public void modifyCardNo(User user) {
		userNewMapper.modifyCardNo(user);
	}

	@Override
	public List<AppUserLabel> getMyLabels(long userId) {
		return userNewMapper.getMyLabels(userId);
	}
}